From 5285d4587d41363ffe58b15a585618fc0e9e7316 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Mon, 28 Apr 2014 15:34:51 +0200 Subject: [PATCH] improve how RGBA buffers are copied to n_component --- babl/babl-fish-reference.c | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c index 05172da..6d0f270 100644 --- a/babl/babl-fish-reference.c +++ b/babl/babl-fish-reference.c @@ -270,6 +270,60 @@ ncomponent_convert_from_double (BablFormat *destination_fmt, } +static int +process_same_model2 (const Babl *babl, + const char *source, + char *destination, + long n) +{ + void *double_buf; + +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + + double_buf = babl_malloc (sizeof (double) * n * + MAX (BABL (babl->fish.source)->format.model->components, + BABL (babl->fish.source)->format.components)); +#undef MAX + + if (1) + { + /* FIXME: should recursively invoke babl and look up an appropriate fish + * for the conversion and multiply n by the number of components. + */ + ncomponent_convert_to_double ( + (BablFormat *) BABL (babl->fish.source), + (char *) source, + double_buf, + n + ); + + ncomponent_convert_from_double ( + (BablFormat *) BABL (babl->fish.destination), + double_buf, + (char *) destination, + n + ); + } + else + { + convert_to_double ( + (BablFormat *) BABL (babl->fish.source), + (char *) source, + double_buf, + n + ); + + convert_from_double ( + (BablFormat *) BABL (babl->fish.destination), + double_buf, + (char *) destination, + n + ); + } + babl_free (double_buf); + return 0; +} + static int process_same_model (const Babl *babl, @@ -347,6 +401,13 @@ babl_fish_reference_process (const Babl *babl, BABL (babl->fish.destination)->format.model) return process_same_model (babl, source, destination, n); + if (babl_format_is_format_n (BABL (babl->fish.destination))) + { + return process_same_model2 (babl, source, destination, n); + } + + + source_double_buf = babl_malloc (sizeof (double) * n * BABL (babl->fish.source)->format.model->components); rgba_double_buf = babl_malloc (sizeof (double) * n * 4); -- 2.30.2